package com.gxa.service.department.impl;

import com.gxa.common.R.ResponseData;
import com.gxa.mapper.department.DeptMapper;
import com.gxa.pojo.Dept;
import com.gxa.pojo.Employee;
import com.gxa.service.department.DeptService;
import com.sun.org.apache.bcel.internal.generic.NEW;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class DeptServiceImpl implements DeptService {

    @Autowired(required = false)
    private DeptMapper deptMapper;

    /*
       查询出来的部门分级
    */
    @Override
    public ResponseData findDeptType(String currentPage, String pageSize) {
        ResponseData responseData = new ResponseData();
//        ArrayList<Object> list = new ArrayList<>();
        List<Map<String, String>> depts=deptMapper.findDeptType();
//        list.add(depts);
        responseData.setCode(200);
        responseData.setMsg("查询成功");
        responseData.setData(depts);
        return responseData;
    }
/*
查询出的部门分级
 */
    @Override
    public ResponseData findEmployeeList(String currentPage, String pageSize) {
        ResponseData<Object> data = new ResponseData<>();
        List<Employee>employees=deptMapper.findEmployeeList();
        data.setCode(200);
        data.setMsg("查询成功");
        data.setData(employees);
        return data;
    }
/*
查询部门员工
 */
    @Override
    public ResponseData findEmpInformationList(String currentPage, String pageSize) {
        ResponseData<Object> objectResponseData = new ResponseData<>();
        List<Employee>employeeList=deptMapper.findEmpInformationList();
        objectResponseData.setCode(200);
        objectResponseData.setMsg("查询成功");
        objectResponseData.setData(employeeList);
        return objectResponseData;
    }
/*
查询部门信息
 */
    @Override
    public ResponseData findInformationList(String currentPage, String pageSize) {
        ResponseData<Object> data = new ResponseData<>();
        List<Dept>DeptList=deptMapper.findInformationList();
        data.setCode(200);
        data.setMsg("查询成功");
        data.setData(DeptList);
        return data;
    }
/*
修改部门信息
 */
    @Override
    public ResponseData updateDepartment(Dept dept) {
        ResponseData responseData = new ResponseData();
        deptMapper.updateDepartment(dept);
        responseData.setCode(200);
        responseData.setMsg("修改成功");
        return responseData;
    }
/*
删除部门
 */
    @Override
    public ResponseData deleteDepartment(String id) {
        ResponseData data = new ResponseData();
        deptMapper.deleteDepartment(id);
        data.setCode(200);
        data.setMsg("删除成功");
        return data;
    }
/*
添加部门信息
 */
    @Override
    public ResponseData insertDepartment(Dept dept) {
        ResponseData data = new ResponseData();
        deptMapper.insertDepartment(dept);
        data.setCode(200);
        data.setMsg("添加成功");
        return data;
    }
/*
部门下拉框
 */
    @Override
    public ResponseData chooseDepartment(int type) {
        ResponseData data = new ResponseData();
        List<Dept> deptList = deptMapper.chooseDepartment(type);
        data.setCode(200);
        data.setMsg("添加成功");
        data.setData(deptList);
        return data;
    }


}
